package VO;

import java.util.ArrayList;

import Promotion.Discounts;
import Promotion.DiscountsList;

public class DiscountsListVO {
	ArrayList<DiscountsVO> Discountslist=new ArrayList<DiscountsVO>();
	String disID="";
	
	public DiscountsListVO(){}	
	public DiscountsListVO(ArrayList<DiscountsVO>  dislist){
		Discountslist=dislist;
		init();
	}
	public DiscountsListVO(DiscountsList  dislist){
		for(Discounts d: dislist.GetDiscountslist()){
			DiscountsVO disvo=new DiscountsVO(d);
			Discountslist.add(disvo);
		}
		init();
	}
	public DiscountsListVO(String dislistinfo[][]){
		for(String disinfo[]:dislistinfo){
			DiscountsVO dv=new DiscountsVO(disinfo);
			Discountslist.add(dv);
		}
	}
	

	
	public DiscountsListVO(DiscountsListVO dislOfAll,String disidList){
		String[] disidlist=disidList.split("/");
		if(disidList.equals("")){
			for(String id:disidlist){
				DiscountsVO gconvo=dislOfAll.find(Long.parseLong(id));
				Discountslist.add(gconvo);
			}
			init();
		}		
	}
	public void init(){
		for(DiscountsVO dis:Discountslist){
			disID=disID+"/"+dis.getID();
		}
	}

	public DiscountsVO find(long id){
		DiscountsVO dis=null;
		for(DiscountsVO d:Discountslist){
			if(d.getID()==id){
				dis=d;
				break;
			}
		}
		return dis;
	}
	public ArrayList<DiscountsVO> getDiscountslist(){
		return Discountslist;
	}
	public String getdislid(){
		return disID;
	}

}
